// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch
{
	public sealed partial class TermSuggester : IFieldSuggesterVariant
	{
		[JsonInclude]
		[JsonPropertyName("analyzer")]
		public string? Analyzer { get; set; }

		[JsonInclude]
		[JsonPropertyName("field")]
		public Elastic.Clients.Elasticsearch.Field Field { get; set; }

		[JsonInclude]
		[JsonPropertyName("lowercase_terms")]
		public bool? LowercaseTerms { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_edits")]
		public int? MaxEdits { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_inspections")]
		public int? MaxInspections { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_term_freq")]
		public float? MaxTermFreq { get; set; }

		[JsonInclude]
		[JsonPropertyName("min_doc_freq")]
		public float? MinDocFreq { get; set; }

		[JsonInclude]
		[JsonPropertyName("min_word_length")]
		public int? MinWordLength { get; set; }

		[JsonInclude]
		[JsonPropertyName("prefix_length")]
		public int? PrefixLength { get; set; }

		[JsonInclude]
		[JsonPropertyName("shard_size")]
		public int? ShardSize { get; set; }

		[JsonInclude]
		[JsonPropertyName("size")]
		public int? Size { get; set; }

		[JsonInclude]
		[JsonPropertyName("sort")]
		public Elastic.Clients.Elasticsearch.SuggestSort? Sort { get; set; }

		[JsonInclude]
		[JsonPropertyName("string_distance")]
		public Elastic.Clients.Elasticsearch.StringDistance? StringDistance { get; set; }

		[JsonInclude]
		[JsonPropertyName("suggest_mode")]
		public Elastic.Clients.Elasticsearch.SuggestMode? SuggestMode { get; set; }

		[JsonInclude]
		[JsonPropertyName("text")]
		public string? Text { get; set; }
	}

	public sealed partial class TermSuggesterDescriptor<TDocument> : SerializableDescriptorBase<TermSuggesterDescriptor<TDocument>>
	{
		internal TermSuggesterDescriptor(Action<TermSuggesterDescriptor<TDocument>> configure) => configure.Invoke(this);
		public TermSuggesterDescriptor() : base()
		{
		}

		private string? AnalyzerValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }

		private bool? LowercaseTermsValue { get; set; }

		private int? MaxEditsValue { get; set; }

		private int? MaxInspectionsValue { get; set; }

		private float? MaxTermFreqValue { get; set; }

		private float? MinDocFreqValue { get; set; }

		private int? MinWordLengthValue { get; set; }

		private int? PrefixLengthValue { get; set; }

		private int? ShardSizeValue { get; set; }

		private int? SizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.SuggestSort? SortValue { get; set; }

		private Elastic.Clients.Elasticsearch.StringDistance? StringDistanceValue { get; set; }

		private Elastic.Clients.Elasticsearch.SuggestMode? SuggestModeValue { get; set; }

		private string? TextValue { get; set; }

		public TermSuggesterDescriptor<TDocument> Analyzer(string? analyzer)
		{
			AnalyzerValue = analyzer;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Field field)
		{
			FieldValue = field;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> Field<TValue>(Expression<Func<TDocument, TValue>> field)
		{
			FieldValue = field;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> LowercaseTerms(bool? lowercaseTerms = true)
		{
			LowercaseTermsValue = lowercaseTerms;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> MaxEdits(int? maxEdits)
		{
			MaxEditsValue = maxEdits;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> MaxInspections(int? maxInspections)
		{
			MaxInspectionsValue = maxInspections;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> MaxTermFreq(float? maxTermFreq)
		{
			MaxTermFreqValue = maxTermFreq;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> MinDocFreq(float? minDocFreq)
		{
			MinDocFreqValue = minDocFreq;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> MinWordLength(int? minWordLength)
		{
			MinWordLengthValue = minWordLength;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> PrefixLength(int? prefixLength)
		{
			PrefixLengthValue = prefixLength;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> ShardSize(int? shardSize)
		{
			ShardSizeValue = shardSize;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> Size(int? size)
		{
			SizeValue = size;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> Sort(Elastic.Clients.Elasticsearch.SuggestSort? sort)
		{
			SortValue = sort;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> StringDistance(Elastic.Clients.Elasticsearch.StringDistance? stringDistance)
		{
			StringDistanceValue = stringDistance;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> SuggestMode(Elastic.Clients.Elasticsearch.SuggestMode? suggestMode)
		{
			SuggestModeValue = suggestMode;
			return Self;
		}

		public TermSuggesterDescriptor<TDocument> Text(string? text)
		{
			TextValue = text;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (!string.IsNullOrEmpty(AnalyzerValue))
			{
				writer.WritePropertyName("analyzer");
				writer.WriteStringValue(AnalyzerValue);
			}

			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
			if (LowercaseTermsValue.HasValue)
			{
				writer.WritePropertyName("lowercase_terms");
				writer.WriteBooleanValue(LowercaseTermsValue.Value);
			}

			if (MaxEditsValue.HasValue)
			{
				writer.WritePropertyName("max_edits");
				writer.WriteNumberValue(MaxEditsValue.Value);
			}

			if (MaxInspectionsValue.HasValue)
			{
				writer.WritePropertyName("max_inspections");
				writer.WriteNumberValue(MaxInspectionsValue.Value);
			}

			if (MaxTermFreqValue.HasValue)
			{
				writer.WritePropertyName("max_term_freq");
				writer.WriteNumberValue(MaxTermFreqValue.Value);
			}

			if (MinDocFreqValue.HasValue)
			{
				writer.WritePropertyName("min_doc_freq");
				writer.WriteNumberValue(MinDocFreqValue.Value);
			}

			if (MinWordLengthValue.HasValue)
			{
				writer.WritePropertyName("min_word_length");
				writer.WriteNumberValue(MinWordLengthValue.Value);
			}

			if (PrefixLengthValue.HasValue)
			{
				writer.WritePropertyName("prefix_length");
				writer.WriteNumberValue(PrefixLengthValue.Value);
			}

			if (ShardSizeValue.HasValue)
			{
				writer.WritePropertyName("shard_size");
				writer.WriteNumberValue(ShardSizeValue.Value);
			}

			if (SizeValue.HasValue)
			{
				writer.WritePropertyName("size");
				writer.WriteNumberValue(SizeValue.Value);
			}

			if (SortValue is not null)
			{
				writer.WritePropertyName("sort");
				JsonSerializer.Serialize(writer, SortValue, options);
			}

			if (StringDistanceValue is not null)
			{
				writer.WritePropertyName("string_distance");
				JsonSerializer.Serialize(writer, StringDistanceValue, options);
			}

			if (SuggestModeValue is not null)
			{
				writer.WritePropertyName("suggest_mode");
				JsonSerializer.Serialize(writer, SuggestModeValue, options);
			}

			if (!string.IsNullOrEmpty(TextValue))
			{
				writer.WritePropertyName("text");
				writer.WriteStringValue(TextValue);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class TermSuggesterDescriptor : SerializableDescriptorBase<TermSuggesterDescriptor>
	{
		internal TermSuggesterDescriptor(Action<TermSuggesterDescriptor> configure) => configure.Invoke(this);
		public TermSuggesterDescriptor() : base()
		{
		}

		private string? AnalyzerValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }

		private bool? LowercaseTermsValue { get; set; }

		private int? MaxEditsValue { get; set; }

		private int? MaxInspectionsValue { get; set; }

		private float? MaxTermFreqValue { get; set; }

		private float? MinDocFreqValue { get; set; }

		private int? MinWordLengthValue { get; set; }

		private int? PrefixLengthValue { get; set; }

		private int? ShardSizeValue { get; set; }

		private int? SizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.SuggestSort? SortValue { get; set; }

		private Elastic.Clients.Elasticsearch.StringDistance? StringDistanceValue { get; set; }

		private Elastic.Clients.Elasticsearch.SuggestMode? SuggestModeValue { get; set; }

		private string? TextValue { get; set; }

		public TermSuggesterDescriptor Analyzer(string? analyzer)
		{
			AnalyzerValue = analyzer;
			return Self;
		}

		public TermSuggesterDescriptor Field(Elastic.Clients.Elasticsearch.Field field)
		{
			FieldValue = field;
			return Self;
		}

		public TermSuggesterDescriptor Field<TDocument, TValue>(Expression<Func<TDocument, TValue>> field)
		{
			FieldValue = field;
			return Self;
		}

		public TermSuggesterDescriptor Field<TDocument>(Expression<Func<TDocument, object>> field)
		{
			FieldValue = field;
			return Self;
		}

		public TermSuggesterDescriptor LowercaseTerms(bool? lowercaseTerms = true)
		{
			LowercaseTermsValue = lowercaseTerms;
			return Self;
		}

		public TermSuggesterDescriptor MaxEdits(int? maxEdits)
		{
			MaxEditsValue = maxEdits;
			return Self;
		}

		public TermSuggesterDescriptor MaxInspections(int? maxInspections)
		{
			MaxInspectionsValue = maxInspections;
			return Self;
		}

		public TermSuggesterDescriptor MaxTermFreq(float? maxTermFreq)
		{
			MaxTermFreqValue = maxTermFreq;
			return Self;
		}

		public TermSuggesterDescriptor MinDocFreq(float? minDocFreq)
		{
			MinDocFreqValue = minDocFreq;
			return Self;
		}

		public TermSuggesterDescriptor MinWordLength(int? minWordLength)
		{
			MinWordLengthValue = minWordLength;
			return Self;
		}

		public TermSuggesterDescriptor PrefixLength(int? prefixLength)
		{
			PrefixLengthValue = prefixLength;
			return Self;
		}

		public TermSuggesterDescriptor ShardSize(int? shardSize)
		{
			ShardSizeValue = shardSize;
			return Self;
		}

		public TermSuggesterDescriptor Size(int? size)
		{
			SizeValue = size;
			return Self;
		}

		public TermSuggesterDescriptor Sort(Elastic.Clients.Elasticsearch.SuggestSort? sort)
		{
			SortValue = sort;
			return Self;
		}

		public TermSuggesterDescriptor StringDistance(Elastic.Clients.Elasticsearch.StringDistance? stringDistance)
		{
			StringDistanceValue = stringDistance;
			return Self;
		}

		public TermSuggesterDescriptor SuggestMode(Elastic.Clients.Elasticsearch.SuggestMode? suggestMode)
		{
			SuggestModeValue = suggestMode;
			return Self;
		}

		public TermSuggesterDescriptor Text(string? text)
		{
			TextValue = text;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (!string.IsNullOrEmpty(AnalyzerValue))
			{
				writer.WritePropertyName("analyzer");
				writer.WriteStringValue(AnalyzerValue);
			}

			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
			if (LowercaseTermsValue.HasValue)
			{
				writer.WritePropertyName("lowercase_terms");
				writer.WriteBooleanValue(LowercaseTermsValue.Value);
			}

			if (MaxEditsValue.HasValue)
			{
				writer.WritePropertyName("max_edits");
				writer.WriteNumberValue(MaxEditsValue.Value);
			}

			if (MaxInspectionsValue.HasValue)
			{
				writer.WritePropertyName("max_inspections");
				writer.WriteNumberValue(MaxInspectionsValue.Value);
			}

			if (MaxTermFreqValue.HasValue)
			{
				writer.WritePropertyName("max_term_freq");
				writer.WriteNumberValue(MaxTermFreqValue.Value);
			}

			if (MinDocFreqValue.HasValue)
			{
				writer.WritePropertyName("min_doc_freq");
				writer.WriteNumberValue(MinDocFreqValue.Value);
			}

			if (MinWordLengthValue.HasValue)
			{
				writer.WritePropertyName("min_word_length");
				writer.WriteNumberValue(MinWordLengthValue.Value);
			}

			if (PrefixLengthValue.HasValue)
			{
				writer.WritePropertyName("prefix_length");
				writer.WriteNumberValue(PrefixLengthValue.Value);
			}

			if (ShardSizeValue.HasValue)
			{
				writer.WritePropertyName("shard_size");
				writer.WriteNumberValue(ShardSizeValue.Value);
			}

			if (SizeValue.HasValue)
			{
				writer.WritePropertyName("size");
				writer.WriteNumberValue(SizeValue.Value);
			}

			if (SortValue is not null)
			{
				writer.WritePropertyName("sort");
				JsonSerializer.Serialize(writer, SortValue, options);
			}

			if (StringDistanceValue is not null)
			{
				writer.WritePropertyName("string_distance");
				JsonSerializer.Serialize(writer, StringDistanceValue, options);
			}

			if (SuggestModeValue is not null)
			{
				writer.WritePropertyName("suggest_mode");
				JsonSerializer.Serialize(writer, SuggestModeValue, options);
			}

			if (!string.IsNullOrEmpty(TextValue))
			{
				writer.WritePropertyName("text");
				writer.WriteStringValue(TextValue);
			}

			writer.WriteEndObject();
		}
	}
}